package com.gdkm.dao;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import com.gdkm.po.Medical;

@Repository
@Mapper
public interface MedicalDao {

	@Insert("insert into medical_record(m_name,m_type,m_symptom,m_grade,m_phone,m_sex,dateOfOnSet,dateOfConsultation) "
			+ "values(#{m_name},#{m_type},#{m_symptom},#{m_grade},#{m_phone},#{m_sex},#{dateOfOnSet},#{dateOfConsultation})")
	void save1(String m_name, String m_type, String m_symptom, String m_grade, String m_phone, String m_sex,
			String dateOfOnSet, String dateOfConsultation);

	@Select("SELECT * FROM medical_record WHERE m_name LIKE concat('%',#{m_name},'%') && m_grade LIKE concat('%',#{m_grade},'%') limit #{y},#{ge}")
	List<Medical> list3(String m_name, String m_grade, int y, int ge);

	@Select("SELECT * FROM medical_record  limit #{y},#{ge}")
	List<Medical> list2(int y, int ge);

	@Update("UPDATE  medical_record set m_name=#{m_name},m_type=#{m_type},m_symptom=#{m_symptom},m_grade=#{m_grade},m_phone=#{m_phone},m_sex=#{m_sex},dateOfOnSet=#{dateOfOnSet},dateOfConsultation=#{dateOfConsultation} where id=#{id}")
	void update(Medical stu);

	@Delete("DELETE FROM medical_record where id=#{id}")
	void delete1(int id);

	@Select("SELECT * FROM medical_record where m_name=#{m_name}")
    List<Medical> list4(String m_name);
}
